<?php
if (theme_get_setting('vietnamsoft_fixed')) {
  drupal_add_css(path_to_theme() . '/vietnamsoft-fixed.css', 'theme', 'all');
}


/**
 * Implementation of HOOK_theme().
 */
function vietnamsoft_theme(&$existing, $type, $theme, $path) {
  return zen_theme($existing, $type, $theme, $path);
}

/**
 * Override or insert PHPTemplate variables into all templates.
 *
 * @param $vars
 *   A sequential array of variables to pass to the theme template.
 * @param $hook
 *   The name of the theme function being called (name of the .tpl.php file.)
 */
function vietnamsoft_preprocess(&$vars, $hook) {
  if ($hook == 'page') {
    if ($menu_footer_links_source = variable_get ('menu_footer_links_source', '')) {
      $footer_links = menu_navigation_links($menu_footer_links_source, 0);
      
      $vars['footer_message'] .= ' | ' . theme(
        'links', 
        $footer_links, 
        array('class' => 'inline links', 'id' => 'footer-links')
      );
    }
  }
}

/**
 * The rel="nofollow" attribute is missing from anonymous users' URL in Drupal 6.0-6.2.
 */
function vietnamsoft_username($object) {

  if ($object->uid && $object->name) {
    // Shorten the name when it is too long or it will break many tables.
    if (drupal_strlen($object->name) > 20) {
      $name = drupal_substr($object->name, 0, 15) . '...';
    }
    else {
      $name = $object->name;
    }

    if (user_access('access user profiles')) {
      $output = l($name, 'user/' . $object->uid, array('attributes' => array('title' => t('View user profile.'))));
    }
    else {
      $output = check_plain($name);
    }
  }
  else if ($object->name) {
    // Sometimes modules display content composed by people who are
    // not registered members of the site (e.g. mailing list or news
    // aggregator modules). This clause enables modules to display
    // the true author of the content.
    if (!empty($object->homepage)) {
      $output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow')));
    }
    else {
      $output = check_plain($object->name);
    }

    $output .= ' (' . t('not verified') . ')';
  }
  else {
    $output = variable_get('anonymous', t('Anonymous'));
  }

  return $output;
}
